﻿using Service.Auth.Model.Enum;
using Service.Repository;
using SqlSugar;

namespace Service.Auth.Domain.AggregatesModel
{
    [SugarTable("tb_client")]
    public class AuthClient : Entity, IAggregateRoot
    {
        public AuthClient()
        {
        }

        public AuthClient(bool allowOpenId, bool allowProfile, string clientId, string clientName, string clientSecret, GrantTypeEnum grantTypes, string remark, int tokenTimeOut)
        {
            AllowOpenId = allowOpenId;
            AllowProfile = allowProfile;
            ClientId = clientId;
            ClientName = clientName;
            ClientSecret = clientSecret;
            GrantTypes = grantTypes;
            Remark = remark;
            TokenTimeOut = tokenTimeOut;
        }

        /// <summary>
        /// 允许OpenId(0、不允许 1、允许)
        /// </summary>
        [SugarColumn(ColumnName = "allowOpenId")]
        public Boolean AllowOpenId
        {
            set; get;
        }

        /// <summary>
        /// 允许Profile(0、不允许 1、允许)
        /// </summary>
        [SugarColumn(ColumnName = "allowProfile")]
        public Boolean AllowProfile
        {
            set; get;
        }

        /// <summary>
        /// 客户端Id
        /// </summary>
        [SugarColumn(ColumnName = "client_id", IsPrimaryKey = true)]
        public String ClientId
        {
            set; get;
        }

        /// <summary>
        /// 客户端名称
        /// </summary>
        [SugarColumn(ColumnName = "client_name", IsPrimaryKey = true)]
        public String ClientName
        {
            set; get;
        }

        /// <summary>
        /// 客户端密码
        /// </summary>
        [SugarColumn(ColumnName = "client_secret")]
        public String ClientSecret
        {
            set; get;
        }

        /// <summary>
        /// 授予类别
        /// <Remark>
        /// 1、密码验证模式
        /// 2、客户端验证模式
        /// 3、密码、客户端复合模式
        /// 4、长期机密客户端访问模式(OpenId协议)
        /// 5、客户端、长期机密客户端访问模式(OpenId协议) 复合模式
        /// </Remark>
        /// </summary>
        [SugarColumn(ColumnName = "grantTypes")]
        public GrantTypeEnum GrantTypes
        {
            set; get;
        }


        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(ColumnName = "remark")]
        public String Remark
        {
            set; get;
        }


        /// <summary>
        /// Token过期时间  单位(秒)
        /// </summary>
        [SugarColumn(ColumnName = "tokenTimeOut")]
        public Int32 TokenTimeOut
        {
            set; get;
        }

    }
}
